package com.hopster;

import java.util.Calendar;

import android.os.Bundle;


public class Event implements Comparable
{	//Data members
	private String name, description, location;
	private Calendar startCalendar, endCalendar;
	
	//Constructors
	public Event(String name, String description, String location, Calendar startCalendar, Calendar endCalendar)
	{
		this.name = name;
		this.description = description;
		this.location = location;
		
		this.startCalendar = startCalendar;
		this.endCalendar = endCalendar;
	}
	
	//getters and setters
	public String getName()
	{
		return name;
	}
	
	public String getDescription()
	{
		return description;
	}
	
	public String getLocation()
	{
		return location;
	}
	
	public Calendar getStartCalendar()
	{
		return startCalendar;
	}
	
	public Calendar getEndCalendar()
	{
		return endCalendar;
	}
	
	public Bundle passEvent(int id)
	{
		Bundle events = new Bundle();
		events.putString("name", name);
		events.putString("description", description);
		events.putString("location", location);
		events.putInt("sHour", startCalendar.get(Calendar.HOUR));
		events.putInt("sMinute", startCalendar.get(Calendar.MINUTE));
		events.putInt("sDay", startCalendar.get(Calendar.DAY_OF_MONTH));
        events.putInt("sMonth", startCalendar.get(Calendar.MONTH));
        events.putInt("sYear", startCalendar.get(Calendar.YEAR));
        events.putInt("sWkday", startCalendar.get(Calendar.DAY_OF_WEEK));
        events.putInt("eHour", endCalendar.get(Calendar.HOUR));
		events.putInt("eMinute", endCalendar.get(Calendar.MINUTE));
		events.putInt("eDay", endCalendar.get(Calendar.DAY_OF_MONTH));
        events.putInt("eMonth", endCalendar.get(Calendar.MONTH));
        events.putInt("eYear", endCalendar.get(Calendar.YEAR));
        events.putInt("eWkday", endCalendar.get(Calendar.DAY_OF_WEEK));
        events.putInt("eventID", id);
		return events;
	}
	
	public int compareTo(Object o)
	{
		Event other = (Event)o;
		
		if(name.equals(other.getName()))	// If the names are the same, then the events are the same
			return 0;
		if(startCalendar.equals(other.getStartCalendar()))	// If the dates are the same, sort in lexicographical order
			return name.compareTo(other.getName());
		else
			return startCalendar.compareTo(other.getStartCalendar());	// Sort by event start date
		
	}
	
	public boolean equals(Object o)
	{
		Event other = (Event)o;
		return name.equals(other.getName());
	}
}
